xen/hypercall: Don't use BUG() for parameter checking in hypercall_create_continuation()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 31 Oct 2019 16:06:55 +0000 (17:06 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Oct 2019 16:06:55 +0000 (17:06 +0100)
commit00474079f2b00ca031799a057bb0b3e97f17fe3a
treec43d3e7769757008719f04d4e2c1ffb0ce07a48d
parentaebe0554e9ac4e5addb0d3cf25bd51af7dd61821
xen/hypercall: Don't use BUG() for parameter checking in hypercall_create_continuation()

Since c/s 1d429034 "hypercall: update vcpu_op to take an unsigned vcpuid",
which incorrectly swapped 'i' for 'u' in the parameter type list, guests have
been able to hit the BUG() in next_args()'s default case.

Correct these back to 'i'.

In addition, make adjustments to prevent this class of issue from occurring in
the future - crashing Xen is not an appropriate form of parameter checking.

Capitalise NEXT_ARG() to catch all uses, to highlight that it is a macro doing
non-function-like things behind the scenes, and undef it when appropriate.
Implement a bad_fmt: block which prints an error, asserts unreachable, and
crashes the guest.

On the ARM side, drop all parameter checking of p.  It is asymmetric with the
x86 side, and akin to expecting memcpy() or sprintf() to check their src/fmt
parameter before use.  A caller passing "" or something other than a string
literal will be obvious during code review.

This is XSA-296.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
master commit: 0bf9f8d3e399a0e1d2b717f71b4776172446184b
master date: 2019-10-31 16:07:11 +0100
xen/arch/arm/domain.c
xen/arch/x86/hypercall.c
xen/common/compat/domain.c
xen/common/domain.c